package com.zy.sort;

import java.util.Arrays;

/**
 * @Author Gong
 * @Description
 * @dATE 2021/11/28 20:23
 **/
public class SelectSort {
    public static void main(String[] args) {
        int[] ary={3,-1,32,5,9,10};
        for (int i = 0; i < ary.length; i++) {
            int min = i;//最小的下标
            for (int j = i +1; j < ary.length; j++) {
                if(ary[j]< ary[min]){
                    min = j;
                }
            }
            //此时完毕找到的min是真正的最小值
            System.out.println(ary[min]);
            if(ary[i] != ary[min]){
                int temp = ary[i];
                ary[i] =  ary[min];
                ary[min] = temp;

            }
        }
        System.out.println(Arrays.toString(ary));
        
    }
}
